package com.project.microweatherservice.controller.publicapi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.project.microweatherservice.service.WeatherDataService;
import com.project.microweatherservice.vo.WeatherResponse;

@RestController
@RequestMapping("/weather")
public class WeatherApi {

	@Autowired
	private WeatherDataService weatherDataService;
	
	@RequestMapping(value = "/city/id/{cityId}", method = RequestMethod.GET)
	public WeatherResponse getWeatherDataByCityId(@PathVariable Integer cityId) {
		return weatherDataService.getDataByCityId(cityId);
	}
	
	@RequestMapping(value = "/city/name/{cityName}", method = RequestMethod.GET)
	public WeatherResponse getWeatherDataByCityName(@PathVariable("cityName") String cityName) {
		return weatherDataService.getDataByCityName(cityName);
	}
}
